<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];

$vals	= mssql_query("SELECT * FROM Pribadi WHERE NIK='$nik'",$conn);
$nums	= mssql_num_rows($vals);

if($nums > 0){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("SELECT * FROM Pribadi WHERE NIK='$nik' ",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Simpan";
}

include("../header.php");
?>
<script type="text/javascript">
	function LoadFocus(){
		document.forms[0].elements[0].focus();
	}
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){
		if(document.FEmployee.nik.value == "")
		{
			alert("Field : NIK tidak boleh kosong ...");
			document.FEmployee.nik.focus();
			return false;
		}

		if(document.FEmployee.nama_kampus.value == "")
		{
			alert("Field : Nama Kampus tidak boleh kosong ...");
			document.FEmployee.nama_kampus.focus();
			return false;
		}
		/*
		if(document.FEmployee.fakultas.value == "")
		{
			alert("Field : Fakultas tidak boleh kosong ...");
			document.FEmployee.fakultas.focus();
			return false;
		}
		*/
		if(document.FEmployee.jenjang.value == "")
		{
			alert("Field : Jenjang Pendidikan tidak boleh kosong ...");
			document.FEmployee.jenjang.focus();
			return false;
		}
/*
		if(document.FEmployee.spesialisasi.value == "")
		{
			alert("Field : Spesialisasi tidak boleh kosong ...");
			document.FEmployee.spesialisasi.focus();
			return false;
		}

		if(document.FEmployee.keahlian.value == "")
		{
			alert("Field : Keahlian tidak boleh kosong ...");
			document.FEmployee.keahlian.focus();
			return false;
		}

		if(document.FEmployee.studi.value == "")
		{
			alert("Field : Studi tidak boleh kosong ...");
			document.FEmployee.studi.focus();
			return false;
		}

		if(document.FEmployee.tugas_akhir.value == "")
		{
			alert("Field : Tugas Akhir tidak boleh kosong ...");
			document.FEmployee.tugas_akhir.focus();
			return false;
		}
*/
		if(document.FEmployee.tinggi.value == "")
		{
			alert("Field : Tinggi tidak boleh kosong ...");
			document.FEmployee.tinggi.focus();
			return false;
		}

		if(document.FEmployee.berat.value == "")
		{
			alert("Field : Berat tidak boleh kosong ...");
			document.FEmployee.berat.focus();
			return false;
		}
/*
		if(document.FEmployee.hobby.value == "")
		{
			alert("Field : Hobby tidak boleh kosong ...");
			document.FEmployee.hobby.focus();
			return false;
		}

		if(document.FEmployee.olahraga.value == "")
		{
			alert("Field : Olahraga tidak boleh kosong ...");
			document.FEmployee.olahraga.focus();
			return false;
		}
*/		
		document.FEmployee.submit();
		
	}

	function disable_enable(){
	if (document.all || document.getElementById){
		if (document.FEmployee.waktu_sakit.disabled==true){
			document.FEmployee.waktu_sakit=false
		}
		else{
			document.FEmployee.waktu_sakit=true
		}
	}
}
	
</script>
<form name="FEmployee" method="post" action="<?=$Faction?>">
<table width="100%">
 <tr>
  <td colspan="2">
	<table width="100%" style="border:none;" cellpadding="0" cellspacing="0">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>Data Pribadi</b></td>
	</tr>
	<tr>
	 <tr>
	  <td>&nbsp;</td>
	 <td align="right" class="line_bottom">
	 <a href="../lib/detailemp.php?show=pribadi&amp;nik=<?=$nik?>"><b>Data Pribadi</b></a> &raquo; 
	 <a href="../lib/detailemp.php?show=data_umum&amp;nik=<?=$nik?>">Data Umum</a> &raquo; 
	 <a href="../lib/detailemp.php?show=pendidikan&amp;nik=<?=$nik?>">Pendidikan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=kecakapan&amp;nik=<?=$nik?>">Kecakapan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=keluarga&amp;nik=<?=$nik?>">Keluarga</a> &raquo; 
	 <a href="../lib/detailemp.php?show=karir&amp;nik=<?=$nik?>">Pengalaman</a> &raquo; 
	 <a href="../lib/detailemp.php?show=organisasi&amp;nik=<?=$nik?>">Organisasi</a> 
	 </td>
	 </tr>
	</table>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td>
  <table border=0 width="100%">
   <tr>
  <td width="100"><b>NIK</b></td>
  <td>: <input type="text" maxlength="10" value="<?=$nik?>" style="font-weight:bold;" class="text" name="nik" readonly=""/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Nama Kampus</td>
  <td>: <input type="text" size="25" maxlength="50" value="<?=$row[Nm_Kampus]?>" class="text" name="nama_kampus"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Fakultas</td>
  <td>: <input type="text" size="25" maxlength="50" value="<?=$row[Fakultas]?>" class="text" name="fakultas"/></td>
 </tr>
 <tr>
  <td>Jenjang Pendidikan</td>
  <td>: 
  <select name="jenjang">
  <?
  	$sPa	= mssql_query("SELECT * FROM MstPendidikan Where Pend_ID='$row[Pend_ID]'",$conn);
	$rPa 	= mssql_fetch_array($sPa);
	echo"<option value='$rPa[Pend_ID]'>$rPa[keterangan] - $rPa[jurusan]</option>";
	
  ?>
  <option value="">-Select-</option>
  <?
  	$sP	= mssql_query("SELECT * FROM MstPendidikan ORDER BY keterangan, jurusan",$conn);
	while($rP = mssql_fetch_array($sP)){
		echo"<option value='$rP[Pend_ID]'>$rP[keterangan] - $rP[jurusan]</option>";
	}
  ?>
  </select>
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Spesialisasi</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Spesialisasi]?>" class="text" name="spesialisasi"/></td>
 </tr>
 <tr>
  <td>Keahlian</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Keahlian]?>" class="text" name="keahlian"/></td>
 </tr>
 <tr>
  <td>Studi</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Studi]?>" class="text" name="studi"/></td>
 </tr>
 <tr>
  <td>Tugas Akhir</td>
  <td>: <input type="text" maxlength="150" value="<?=$row[TugasAkhir]?>" class="text" name="tugas_akhir"/></td>
  <!--<span class="InfoForm">Format: dd/mm/yyyy</span>-->
  </td>
 </tr>
 <tr>
  <td>Tinggi</td>
  <td>: <input type="text" maxlength="3" value="<?=$row[Tinggi]?>" size="6" class="text" name="tinggi"/> Cm, &nbsp;&nbsp;Berat Badan : <input type="text" maxlength="3" name="berat" value="<?=$row[Berat]?>" size="6" /> Kg</td>
 </tr>
 <tr>
  <td>Hobby</td>
  <td align="left">: <input type="text" maxlength="40" size="25" class="text" value="<?=$row[Hobby]?>" name="hobby"/>
  </td>
 </tr>
 <tr>
  <td>Olahraga</td>
  <td>: <input type="text" maxlength="40" size="25" class="text" value="<?=$row[OlahRaga]?>" name="olahraga"/></td>
 </tr>
 <tr>
  <td>Pernah Sakit Keras</td>
  <td valign="middle">: 
  <?
  	if($row[SakitKeras] == 1)
	{
		//$check = "checked='checked'";
  		echo'<input type="radio" name="sakit_keras" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
  		echo'<input type="radio" name="sakit_keras" value="0" title="Tidak" alt="Tidak" /> Tidak';
	}
	elseif($row[SakitKeras] == 0)
	{
		//$check = "";	
  		echo'<input type="radio" name="sakit_keras" value="1" title="Ya" alt="Ya" /> Ya';
  		echo'<input type="radio" name="sakit_keras" value="0" title="Tidak" alt="Tidak" checked="checked" /> Tidak';
	}
	?>
  </td>
  </span> 
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>
  <p>
&nbsp;&nbsp;&nbsp;&nbsp;
<label>Waktu Sakit</label><br />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" maxlength="10" size="25" class="text" value="<?=$row[WaktuSakit]?>" name="waktu_sakit" /> </p>
&nbsp;&nbsp;&nbsp;&nbsp;
<label>Nama Penyakit</label><br />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" maxlength="10" size="25" class="text" value="<?=$row[NamaPenyakit]?>" name="nama_penyakit" />  <br /><br /><br />
   </td>
 </tr>
 <tr>
  <td>Kecelakaan</td>
  <td>: 
  <?
  	if($row[Kecelakaan] == 1)
	{
  		echo'<input type="radio" name="kecelakaan" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
		echo'<input type="radio" name="kecelakaan" value="0" title="Tidak" /> Tidak';
	}
	else{
  		echo'<input type="radio" name="kecelakaan" value="1" title="Ya" alt="Ya"  /> Ya';
		echo'<input type="radio" name="kecelakaan" value="0" title="Tidak" checked="checked" /> Tidak';
	}
	?>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;Waktu Kecelakaan <br />&nbsp;&nbsp;&nbsp;  <input type="text" maxlength="50" size="40" class="text" value="<?=$row[WaktuCelaka]?>" name="waktu_celaka"/> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Kecelakaan Apa <br />&nbsp;&nbsp;&nbsp; <input type="text" maxlength="50" size="40" class="text" value="<?=$row[JenisCelaka]?>" name="jenis_celaka"/> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Akibat Kecelakaan <br />&nbsp;&nbsp;&nbsp; <input type="text" maxlength="50" size="40" class="text" value="<?=$row[AkibatCelaka]?>" name="akibat_celaka"/> </p>
 <br />
   </td>
 </tr>
 <tr>
  <td>Pernah Terlibat Kegiatan Terlarang</td>
  <td>: 
  <?
  	if($row[Terlarang] == 1)
	{
  		echo'<input type="radio" name="terlarang" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
		echo'<input type="radio" name="terlarang" value="0" title="Tidak" /> Tidak';
	}
	else{
  		echo'<input type="radio" name="terlarang" value="1" title="Ya" alt="Ya"  /> Ya';
		echo'<input type="radio" name="terlarang" value="0" title="Tidak" checked="checked" /> Tidak';
	}
	?>
  
<!--  
  <input type="radio" name="terlarang" value="1" title="Ya" alt="Ya" /> Ya
  <input type="radio" name="terlarang" value="0" title="Tidak" checked="checked" /> Tidak -->
  </td>
 </tr>
 <tr>
  <td>Pernah Berurusan dengan Kepolisian</td>
  <td>: 
  <?
  	if($row[UrusanKepolisian] == 1)
	{
  		echo'<input type="radio" name="urusanpolisi" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
		echo'<input type="radio" name="urusanpolisi" value="0" title="Tidak" /> Tidak';
	}
	else{
  		echo'<input type="radio" name="urusanpolisi" value="1" title="Ya" alt="Ya"  /> Ya';
		echo'<input type="radio" name="urusanpolisi" value="0" title="Tidak" checked="checked" /> Tidak';
	}
	?>
<!--  
  <input type="radio" name="urusanpolisi" value="1" title="Ya" alt="Ya"/> Ya
  <input type="radio" name="urusanpolisi" value="0" title="Tidak" checked="checked" /> Tidak-->
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>&nbsp;&nbsp;&nbsp;&nbsp;Jelaskan:<br />
  &nbsp;&nbsp;&nbsp;&nbsp;<textarea name="jenis_urusan" cols="45" rows="5"><?=$row[JenisUrusan]?></textarea>
  </td>
 </tr>
 <tr>
  <td>Pernah terdaftar program ASTEK</td>
  <td>: 
  <?
  	if($row[Astek] == 1)
	{
  		echo'<input type="radio" name="astek" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
		echo'<input type="radio" name="astek" value="0" title="Tidak" /> Tidak';
	}
	else{
  		echo'<input type="radio" name="astek" value="1" title="Ya" alt="Ya"  /> Ya';
		echo'<input type="radio" name="astek" value="0" title="Tidak" checked="checked" /> Tidak';
	}
	?>
<!--  <input type="radio" name="astek" value="1" title="Ya" alt="Ya" /> Ya
  <input type="radio" name="astek" value="0" title="Tidak" checked="checked" /> Tidak-->
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>&nbsp;&nbsp;&nbsp;&nbsp;No. ASTEK : <input type="text" maxlength="15" size="25" class="text" value="<?=$row[NoAstek]?>" name="no_astek"/>  
  </td>
 </tr>
 <tr>
  <td>Pernah mengikuti Penataran P4</td>
  <td>: 
  <?
  	if($row[P4] == 1)
	{
  		echo'<input type="radio" name="penataranp4" value="1" title="Ya" alt="Ya" checked="checked" /> Ya';
		echo'<input type="radio" name="penataranp4" value="0" title="Tidak" /> Tidak';
	}
	else{
  		echo'<input type="radio" name="penataranp4" value="1" title="Ya" alt="Ya"  /> Ya';
		echo'<input type="radio" name="penataranp4" value="0" title="Tidak" checked="checked" /> Tidak';
	}
	?>
 <!-- <input type="radio" name="penataranp4" value="1" title="Ya" alt="Ya" /> Ya
  <input type="radio" name="penataranp4" value="0" title="Tidak" checked="checked" /> Tidak-->
  </td>
 </tr>
  <tr>
  <td>&nbsp;</td>
  <td>&nbsp;&nbsp;&nbsp;&nbsp;Waktu Penataran: <br />
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" maxlength="15" size="25" class="text" value="<?=$row[WaktuP4]?>" name="waktu_penataran"/> 
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td><p>&nbsp;&nbsp;&nbsp;&nbsp;Type Penataran:<br />
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" maxlength="15" size="25" class="text" value="<?=$row[TypeP4]?>" name="type_penataran"/> </p>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td>&nbsp;&nbsp;&nbsp;&nbsp;Penyelenggara: <br />
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" maxlength="30" size="35" class="text" value="<?=$row[PenyelenggaraP4]?>" name="penyelenggara"/> <br /><br />
  </td>
 </tr>
 <tr>
  <td>SIM</td>
  <td>: <input type="text" maxlength="25" size="30" class="text" value="<?=$row[SIM]?>" name="sim"/>  
  </td>
 </tr>
 <tr>
  <td>Tunjangan Sebelumnya</td>
  <td>: <input type="text" maxlength="20" size="25" class="text" value="<?=$row[TunjanganSebelumnya]?>" name="tunjangan"/> 
  </td>
 </tr>
 <tr>
  <td>Gaji</td>
  <td>: <input type="text" maxlength="20" size="25" class="text" value="<?=$row[Gaji]?>" name="gaji"/> 
  </td>
 </tr>
 <tr>
  <td valign="top">Bersedia ditempatkan dimana saja, <br />diseluruh wilayah operasi perusahaan:<br /><br /><br /></td>
  <td valign="top">: 
  <select name="semua_wilayah">
  <?
  	if($row[SemuaWilayah] == 1){
	echo'<option value="1">Ya</option>';
	}
	else{
   	echo'<option value="0">Tidak</option>';
	}
  ?>
   <option value="">-Select-</option>
   <option value="1">Ya</option>
   <option value="0">Tidak</option>
  </select>
  </td>
 </tr>
 <tr>
  <td>Bersedia mematuhi segala peraturan <br />perusahaan yang berlaku, maupun <br />keterangan lain yang akan ditambahkan</td>
  <td>: 
  <select name="semua_peraturan">
  <?
  	if($row[SemuaPeraturan] == 1){
	echo'<option value="1">Ya</option>';
	}
	else{
   	echo'<option value="0">Tidak</option>';
	}
  ?>
   <option value="">-Select-</option>
   <option value="1">Ya</option>
   <option value="0">Tidak</option>
  </select>
  </td>
 </tr>
 <tr>
  <td valign="top">Keterangan</td>
  <td valign="top">&nbsp; 
  <textarea cols="45" rows="5" name="keterangan"><?=$row[Keterangan]?></textarea>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td align="left"><br /><br />
  <input type="hidden" name="cat" value="pribadi" />
  <input type="reset" value="Batal" class="button"/><input type="button" value="<?=$Vbutton?>" class="button" onClick="Validate();" />
  <br /><br />
  </td>
 </tr>
</table>
</form>
</td>
</tr>
<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>

<script type="text/javascript">
//<![CDATA[

var f = document.forms[0];
/*MaskInput(f.elements[0], "(99)9999-9999");
MaskInput(f.elements[1], "99/99/9999");
MaskInput(f.elements[2], "Cc99-*C");
MaskInput(f.elements[3], "E^abc");
MaskInput(f.elements[4], "O^abc");
MaskInput(f.elements[5], "C^");
MaskInput(f.elements[6], "C^ ");
MaskInput(f.elements[7], "9^abc");
*/
MaskInput(f.tinggi,"999");
MaskInput(f.berat,"999");
MaskInput(f.gaji,"999999999999999");
MaskInput(f.tunjangan,"999999999999999");

//]]>
</script>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
